/// @tags: FWT
#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

namespace BlueQuantum {

typedef long long ll;

int const N = 22, M = 2e5 + 5;

int n, m, lim, ans;
char s[N][M];
ll a[1 << N], cnt[1 << N];

inline void FWT(ll *const f, bool typ) {
  for (int i = 0; i < n; ++i)
    for (int j = 0, ed = 1 << n; j < ed; ++j)
      if ((j >> i) & 1) {
        ll x = f[j ^ (1 << i)];
        f[j ^ (1 << i)] = x + f[j], f[j] = x - f[j];
      }
  if (!typ)
    for (int i = 0; i < lim; ++i) a[i] >>= n;
}

inline int main() {
  cin >> n >> m;
  lim = 1 << n;
  for (int i = 0; i < n; ++i) cin >> s[i];
  for (int i = 0; i < m; ++i) {
    int v = 0;
    for (int j = 0; j < n; ++j) v |= (s[j][i] - '0') << j;
    ++a[v];
  }
  for (int i = 1; i < lim; ++i) cnt[i] = cnt[i >> 1] + (i & 1);
  for (int i = 1; i < lim; ++i)
    if (cnt[i] > n - cnt[i]) cnt[i] = n - cnt[i];
  FWT(a, true), FWT(cnt, true);
  for (int i = 0; i < lim; ++i) a[i] = a[i] * cnt[i];
  FWT(a, false);
  ans = n * m;
  for (int i = 0; i < lim; ++i) ans = min(ans, int(a[i]));
  cout << ans;
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("matrix.in", "r", stdin);
  freopen("matrix.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
